<?php
/* @file show-record.php
 * @author Liuexp
 * @description php interface for show record
 */


require_once("helper.php");
if($_GET['op']=='rejudge')
{
	if(!InGroup(GROUP_REJUDGE)){
		MsgBox(ACCESS_DENIED);
		exit();
	}

	$record=$_GET['record'];
	//Note: Even if it failed to find one, it doesn't hurt to create a new one.
	$bean=R::findOne("record","id='$record'");
	$bean->status="pending";
		try{
			R::store($bean);
		}
		catch(Exception $e)
		{
			//TODO
		}
	}
}
else {
	$record=$_GET['record'];
	try{

		$dwoo=new Dwoo();
		$data=new Dwoo_Data();
		if(empty($record)){
			$tpl=new Dwoo_Template_File('./templates/show-record.tpl');
			$bean=R::find("record");
		}
		else
		{
			$tpl=new Dwoo_Template_File('./templates/show-record-detail.tpl');
			$bean=R::findOne("record","id='$record'");
		}
		//$data->assign('sharetronix_user_id',GetUserID());
		$data->assign('record',$bean);
		$dwoo->output($tpl,$data);
	}
	catch(Exception $e)
	{
		OJLog("Error in show-record.php invoking Dwoo:". $e->getMessage());
	}
}
?>
